<?php
header("Content-Type:text/html;charset=utf-8");
include_once "../inc/config.php";
include_once "../inc/config_db.php";
echo "<title>邮件订阅    ".$web_name."</title>";
echo "<style>*{font-size:12px;} div{ text-align:center; width:100%;}</style>";
switch ( $_REQUEST['Action'] )
{

case "add" :
$email=$_POST['email'];
$ip=getenv('REMOTE_ADDR');
$verify="0";
$time = date("Y-m-d H-i-s");
if ($email=="")
{
	echo"<SCRIPT language=JavaScript>alert('邮箱地址不能为空，请重新输入');javascript:history.go(-1);</SCRIPT>";
}
else
{
     if (eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$",$email)) 
      {
		  $sql="select * from tun2_email where email='$email'";
          $result=mysql_fetch_row(mysql_query($sql));
		  if($result){
			 echo"<SCRIPT language=JavaScript>alert('抱歉，此邮箱地址已订阅，无需重复订阅，请重新输入');javascript:history.go(-1);</SCRIPT> "; 
		  }
		  else
		  {
		    $db->query("INSERT INTO tun2_email (email,ip,verify,time) VALUES ('$email','$ip','$verify','$time')");
	        echo "<SCRIPT language=JavaScript>alert('邮件订阅成功!感谢您对".$web_name."的支持！');javascript:history.go(-1);</SCRIPT> ";
		  }
	   }
     else
       {
	        echo "<SCRIPT language=JavaScript>alert('邮箱地址格式不正确，请重新输入');javascript:history.go(-1);</SCRIPT> ";
     	}
}

break;


default :	
echo "<div><form method=\"post\" action=\"?Action=add\" onSubmit=\"return isok(this)\" name=\"theform\">";
echo "<input  type=\"text\" style=\"width: 150px\" name=\"email\" /><input id=\"Submit_Login\" type=\"submit\" style=\"border-bottom: 0px; border-left: 0px; background: #8a658e; height: 21px; width:50px;color: #fff; overflow: visible; border-top: 0px; cursor: pointer; border-right: 0px; padding-top: 0px\" name=\"Submit_Login\" value=\"订阅\" />";
echo "</form></div>";
}
?>
